///*
//package com.rk.admin.utils;
//import com.rk.admin.aop.SystemControllerLog;
//import com.rk.admin.tools.CommonResult;
//import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation;
//import org.springframework.web.bind.annotation.CrossOrigin;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//import java.io.File;
//import java.io.IOException;
//
//
//@RestController
//@CrossOrigin //前后端分离配置跨域访问
//@RequestMapping("/uploadHeadImg")
//public class uploadImgController {
//
//    @ApiOperation("教师头像上传")
//    @SystemControllerLog(description ="上传教师头像")
//    @PostMapping
//    public CommonResult upload(MultipartFile file){
//        System.out.println("前端传入的文件："+file);
//        String originalFilename = file.getOriginalFilename();
//        String savefileName="";
//        if (!file.isEmpty()) {//如果上传的头像不为空
//            //存储头像到tecaherHeadImg目录下
//            //获取文件原来的名字
//            //获取文件类型
//            String fileType = FileNameUtil.getFileType(originalFilename);
//            //更改文件存储的名称，避免上传的文件名重复而覆盖
//            savefileName = FileNameUtil.getUUIDFileName() + fileType;
//
//            //获取项目根路径
//            String path = System.getProperty("user.dir");
//            //获取文件存储路径
//            String savePath = path + "/src/main/resources/image/teacherHeadImg/";
//
//            //文件转存
//            try {
//                file.transferTo(new File(savePath + File.separator + savefileName));
//                System.out.println("存储路径:" + savePath + File.separator + savefileName);
//                return CommonResult.success("/teacherImg/" + savefileName, "头像上传成功!");
//            } catch (IOException e) {
//                e.printStackTrace();
//                return CommonResult.failed("上传失败!");
//            }
//        }
//        return CommonResult.success("/teacherImg/" + savefileName, "头像上传成功!");
//
//    }
//}
//*/
